﻿using Mak_model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mak_bll;

namespace markets
{

    public partial class jiesuan : Form
    {
        /// <summary>
        /// 定义一个data类用来接收选中的数据
        /// </summary>
        public List<data> buylist { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="a"></param>
        public jiesuan()
        {
            InitializeComponent();
           
        }

        luoji lj = new luoji();
        private void button1_Click(object sender, EventArgs e)
        {
            bool ret = lj.InsertOrder(buylist, yingfu, 1);
            if (ret)
            {
                MessageBox.Show("付款成功");
                this.Close();
            }
            else { 
                
                MessageBox.Show("添加数据失败");
               return;
                    
               
            }
        }

        double yingfu = 0.0;
        private void jiesuan_Load(object sender, EventArgs e)
        {

            foreach (data item in buylist)
            {
                yingfu += item.xiaoji;//累加小计
            }
            textBox1.Text = yingfu.ToString();
        }

       
        private void textBox3_KeyUp(object sender, KeyEventArgs e)
        {
            if (textBox3.Text != "")
            {
                double shifu = double.Parse(textBox3.Text);//获取输入的金额
                textBox2.Text = (shifu - yingfu).ToString();
            }
        }

        // if (double.Parse(textBox2.Text) > 0.0)
        //    {

        //        MessageBox.Show("付款成功");
        //    }
        //    else { MessageBox.Show("余额不足"); }
        //}
    }
}
